package common.util
{
	import flash.events.MouseEvent;
	
	import ui.menu.ChildMenuItem;
	import ui.menu.MenuItem;
	import ui.menu.MenuNavItem;

	public class MenuUtil
	{
		public function MenuUtil()
		{
		}
		
		/**
		 * 创建根菜单项目
		 * @id 菜单编号
		 * @icon 菜单图标
		 * @label 菜单名称
		 * @rollOverFun 悬空回调
		 * @rollOutFun 悬空离开回调
		 * @width 宽度
		 * @height 高度
		 */
		public static function createMenuItem(id:String,icon:String,label:String,rollOverFun:Function,width:Number=80,height:Number=80):MenuItem{
			var menuItem:MenuItem = new MenuItem();
			menuItem.width = width;
			menuItem.height = height;
			menuItem.fontSizeInfo = 14;
			
			menuItem.menuId = id;
			menuItem.icon = icon;
			menuItem.label = label;
			menuItem.rollOverFun = rollOverFun;
			return menuItem;
		}
		
		/**
		 * 创建子菜单项目
		 * @id 菜单编号
		 * @icon 菜单图标
		 * @label 菜单名称
		 * @rollOverFun 悬空事件
		 * @rollOutFun 悬空离开事件
		 * @width 宽度
		 * @height 高度
		 */
		public static function createChildMenuItem(id:String,icon:String,label:String,clickFun:Function,width:Number=110,height:Number=25):ChildMenuItem{
			var childMenuItem:ChildMenuItem = new ChildMenuItem();
			childMenuItem.width = width;
			childMenuItem.height = height;
			childMenuItem.fontSizeInfo = 12;
			
			childMenuItem.menuId = id;
			childMenuItem.icon = icon;
			childMenuItem.label = label;
			childMenuItem.addEventListener(MouseEvent.CLICK,clickFun,false,0,true);
			return childMenuItem;
		}
		
		/**
		 * 创建菜单导航项目 
		 */
		public static function createMenuNavItem(id:String,icon:Object,label:String,clickFun:Function,toolTip:String=null):MenuNavItem{
			var menuNavItem:MenuNavItem = new MenuNavItem();
			menuNavItem.menuId = id;
			menuNavItem.icon = icon;
			menuNavItem.label = label;
			menuNavItem.toolTip = toolTip;
			if(clickFun != null){
				menuNavItem.useHandCursor=true;
				menuNavItem.buttonMode=true;
				menuNavItem.mouseChildren=false;
				menuNavItem.addEventListener(MouseEvent.CLICK,clickFun,false,0,true);
				menuNavItem.addRollListener();
			}
			return menuNavItem;
		}
	}
}